package com.iflytek.autofly.setting.util;

import android.os.Environment;

import com.iflytek.autofly.setting.application.MainApplication;
import com.iflytek.autofly.utils.FlyLog;

/**
 * @author 忧郁的西索 ★^_^+
 * @Description: 路径辅助类
 * @date 2013-12-25 上午9:42:56
 */
public class PathUtil {

    private static final String SDFLAG1 = "isExternalSD";
    private static final String SDFLAG2 = "isInternalSD";
    private static final String TAG = "PathUtil";

    /**
     * @param @return
     * @return String
     * @Description: 返回sd卡的根路径
     * @author 忧郁的西索 ★^_^+
     */
    public static String getSDPath() {
        String flag = SpUtil.getString(MainApplication.context, "sdflag", "sdflag", "");
        FlyLog.d(TAG, flag);
        if ("".equals(flag)) {
            if (SDUtil.isSDCardOk()) {
                SpUtil.saveString(MainApplication.context, "sdflag", "sdflag", SDFLAG1);
                return Environment.getExternalStorageDirectory() + "/";
            } else {
                SpUtil.saveString(MainApplication.context, "sdflag", "sdflag", SDFLAG2);
                return getPhoneCardPath();
            }
        } else {
            if (flag.equals(SDFLAG1)) {
                return Environment.getExternalStorageDirectory() + "/";
            } else {
                return getPhoneCardPath();
            }
        }
    }

    /**
     * 获取手机自身内存路径
     */
    public static String getPhoneCardPath() {
        return Environment.getDataDirectory().getPath();
    }

}
